package com.wkbb.basic.controller.open;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.wkbb.basic.constant.BasicConstants;
import com.wkbb.basic.feign.WxFeignService;
import com.wkbb.basic.mapper.YoutuFaceMapper;
import com.wkbb.basic.model.*;
import com.wkbb.basic.service.*;
import com.wkbb.basic.vo.FamilyManageEditVo;
import com.wkbb.basic.vo.StudentManageEditVo;
import com.wkbb.basic.vo.TeacherCourseVo;
import com.wkbb.basic.vo.TeacherManageVo;
import com.wkbb.common.business.BasicBusiness;
import com.wkbb.common.config.ServiceConfig;
import com.wkbb.common.constants.ErrorCode;
import com.wkbb.common.constants.RedisKeyConstant;
import com.wkbb.common.constants.VersionConstant;
import com.wkbb.common.dto.ResultDTO;
import com.wkbb.common.dto.basic.*;
import com.wkbb.common.dto.community.StudentOpenDto;
import com.wkbb.common.dto.smart.SmartWitSchoolConfig;
import com.wkbb.common.dto.wx.AccountDto;
import com.wkbb.common.enums.*;
import com.wkbb.common.redis.RedisTemplateUtil;
import com.wkbb.common.utils.StringUtil;
import com.wkbb.common.utils.UuIdUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * 智慧校园对外接口
 */
@RestController
@Api(description = "组织模块对外接口")
@RequestMapping("/basic/{apiVersion}/open")
@Slf4j
public class CampusController {

    @Autowired
    private OrganizationService organizationService;

    @Autowired
    private GradeService gradeService;

    @Autowired
    private ClassInfoService classInfoService;

    @Autowired
    private OrgStructureService structureService;

    @Autowired
    private StudentService studentService;

    @Autowired
    private UserService userService;

    @Autowired
    private FamilyService familyService;

    @Autowired
    private YouTuService youTuService;

    @Autowired
    private YoutuFaceMapper youtuFaceMapper;

    @Autowired
    private WxFeignService wxFeignService;

    @Autowired
    private EmployeeService employeeService;

    @Autowired
    private OrgStructureUserService orgStructureUserService;

    @Autowired
    private TeacherCourseService teacherCourseService;

    @Autowired
    private OrgStructureService orgStructureService;

    @Autowired
    private TeacherManageService teacherManageService;

    @Autowired
    private ImportLogService importLogService;

    @Autowired
    private RedisTemplateUtil redisTemplateUtil;

    @Autowired
    private OrgServiceConfigService orgServiceConfigService;

    @Autowired
    private ServiceConfig serviceConfig;

    @Autowired
    private PositionService positionService;

    @Autowired
    private UserFaceService userFaceService;

    @Autowired
    private WebankService webankService;

    @Autowired
    private WebankUtilService webankUtilService;

    @Autowired
    private OrganizationWebankService organizationWebankService;

    @Autowired
    private UserOpenService userOpenService;

    private final static List VIDIOSWITCH = new ArrayList<String>() {{
        add("上海进才幼儿园");
        add("宝安格林幼儿园");
        add("峦山谷幼儿园");
        add("城市春天幼儿园");
        add("油松幼儿园");
        add("流塘阳光幼儿园");
        add("超优教育");
        add("南宁市兴宁区超优教育");
        add("爱弥儿国际幼儿园");
        add("敏捷金月湾幼儿园");
        add("广州市天河区汇爱幼儿园");
        add("广州番禺加拿达中英文幼儿园");
        add("荔湾区鹅潭湾艺术幼儿园");
        add("黄埔区沧头幼儿园");
        add("天河区珠江新城海滨幼儿园");
        add("花都区狮岭实验幼儿园");
        add("白云区云天翠庭幼儿园");
        add("朝阳教育试点学校");
        add("增城实验中学");
        add("佛山市时代香海彼岸幼儿园");
    }};

    @ApiOperation(value = "查询智慧校园组织详情")
    @RequestMapping(value = "/getCampusOrganization", method = RequestMethod.GET)
    public ResultDTO<OrganizationDto> getCampusOrganization(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "智慧校园ID", required = true) @RequestParam(name = "smartOrgId", required = true) String smartOrgId) {

        log.info("***********CampusController.getCampusOrganization******apiVersion:{},smartOrgId:{}", apiVersion, smartOrgId);

        try {

            //取缓存
            String organizationRedisKey = BasicBusiness.getSmartOrganizationRedisKey(smartOrgId);
            Organization organization = (Organization) redisTemplateUtil.get(organizationRedisKey);

            //缓存中没有则取数据库
            if (null == organization) {
                Map<String, Object> params = new HashMap<>();
                params.put("smartOrgId", smartOrgId);
                organization = organizationService.getByMapParams(params);

                redisTemplateUtil.set(organizationRedisKey,organization);
            }

            OrganizationDto organizationDto = null;
            if (null != organization) {
                organizationDto = new OrganizationDto();
                BeanUtils.copyProperties(organization, organizationDto);
            }

            return new ResultDTO<OrganizationDto>(organizationDto);

        } catch (Exception e) {
            log.error("***********CampusController.getCampusOrganization******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "新增组织")
    @RequestMapping(value = "/addCampusOrganization", method = RequestMethod.POST)
    public ResultDTO<Long> addCampusOrganization(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织详情", required = true) @RequestBody OrganizationDto organizationDto) {

        log.info("***********CampusController.addCampusOrganization******apiVersion:{},organization:{}", apiVersion, organizationDto);

        try {

            if (null == organizationDto.getParentId()) {
                organizationDto.setParentId(0L);
            }

            if (null == organizationDto.getTypeSet()) {
                organizationDto.setTypeSet(TypeSetEnum.STATE_RUN.getValue().intValue());
            }

            Organization organization = new Organization();
            BeanUtils.copyProperties(organizationDto, organization);

            organization.setCreateBy(SysRoleTypeEnum.SUPER_ADMIN.getDesc());
            organization.setUpdateBy(SysRoleTypeEnum.SUPER_ADMIN.getDesc());
            organizationService.insertOrganization(organization);
            return new ResultDTO<>(organization.getId());

        } catch (Exception e) {
            log.error("***********CampusController.addCampusOrganization******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "更新组织")
    @RequestMapping(value = "/updateCampusOrganization", method = RequestMethod.PUT)
    public ResultDTO<Long> updateCampusOrganization(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织详情", required = true) @RequestBody OrganizationDto organizationDto) {

        log.info("***********CampusController.updateCampusOrganization******apiVersion:{},organization:{}", apiVersion, organizationDto);

        if (organizationDto.getId() == null || organizationDto.getId() == 0) {
            return new ResultDTO<>(ErrorCode.PARAM_MISSING);
        }

        try {

            Organization organization = new Organization();
            BeanUtils.copyProperties(organizationDto, organization);

            organizationService.update(organization, true);

            return new ResultDTO<>(organization.getId());
        } catch (Exception e) {
            log.error("***********CampusController.updateCampusOrganization******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "查询年级")
    @RequestMapping(value = "/getCampusGrade", method = RequestMethod.GET)
    public ResultDTO<GradeDto> getCampusGrade(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "年级ID", required = true) @RequestParam(name = "smartGradeId", required = true) String smartGradeId) {

        log.info("***********CampusController.getCampusGrade******apiVersion:{},smartGradeId:{},orgId:{}", apiVersion, smartGradeId, orgId);

        try {

            Map<String, Object> params = new HashMap<>();
            params.put("smartGradeId", smartGradeId);
            params.put("orgId", orgId);
            Grade grade = gradeService.getByMapParams(params);
            GradeDto gradeDto = null;
            if (null != grade) {
                gradeDto=new GradeDto();
                BeanUtils.copyProperties(grade, gradeDto);
            }
            return new ResultDTO<>(gradeDto);

        } catch (Exception e) {
            log.error("***********CampusController.getCampusGrade******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "新增年级")
    @RequestMapping(value = "/addCampusGrade", method = RequestMethod.POST)
    public ResultDTO<Long> addCampusGrade(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织详情", required = true) @RequestBody GradeDto gradeDto) {

        log.info("***********CampusController.addCampusGrade******apiVersion:{},gradeDto:{}", apiVersion, gradeDto);

        try {

            Grade grade = new Grade();
            BeanUtils.copyProperties(gradeDto, grade);

            //查询上级
            if (!StringUtils.isEmpty(gradeDto.getParentId()) && 0 != gradeDto.getParentId()) {
                Map<String, Object> params = new HashMap<>();
                params.put("smartGradeId", gradeDto.getParentId());

                Grade parentGrade = gradeService.getByMapParams(params);
                if (null != parentGrade) {
                    grade.setParentId(parentGrade.getId());
                }
            }

            gradeService.insert(grade);

            return new ResultDTO<>(true);

        } catch (Exception e) {
            log.error("***********CampusController.addCampusGrade******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "更新年级")
    @RequestMapping(value = "/updateCampusGrade", method = RequestMethod.PUT)
    public ResultDTO<Long> updateCampusGrade(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织详情", required = true) @RequestBody GradeDto gradeDto) {

        log.info("***********CampusController.updateCampusGrade******apiVersion:{},gradeDto:{}", apiVersion, gradeDto);

        if (gradeDto.getId() == null || gradeDto.getId() == 0) {
            return new ResultDTO<>(ErrorCode.PARAM_MISSING);
        }

        try {

            Grade grade = new Grade();
            BeanUtils.copyProperties(gradeDto, grade);

            gradeService.update(grade);

            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********CampusController.updateCampusGrade******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "删除年级")
    @RequestMapping(value = "/deleteCampusGrade", method = RequestMethod.PUT)
    public ResultDTO<Long> deleteGrade(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "年级ID", required = true) @RequestParam(name = "id", required = true) Long id) {

        log.info("***********CampusController.deleteCampusGrade******apiVersion:{},id:{}", apiVersion, id);

        if (id == null) {
            return new ResultDTO<>(ErrorCode.PARAM_MISSING);
        }

        try {
            //先删除所有班级
            HashMap<String, Object> param = new HashMap<>(1);
            param.put("gradeId",id);
            List<ClassInfo> classInfoList = classInfoService.getListByMapParams(param);

            ArrayList<Long> classIdList = new ArrayList<>();
            if(CollectionUtils.isNotEmpty(classInfoList)){
                classInfoList.forEach((e)->{
                    classIdList.add(e.getId());
                });
            }

            if(CollectionUtils.isNotEmpty(classIdList)){
                classInfoService.delete(classIdList,"系统管理员");
            }
            //再删除年级
            gradeService.update(Grade.builder().id(id).status(false).build());
            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********CampusController.deleteCampusGrade******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "查询班级")
    @RequestMapping(value = "/getCampusClass", method = RequestMethod.GET)
    public ResultDTO<ClassInfoDto> getCampusClass(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "班级ID", required = true) @RequestParam(name = "smartClassId", required = true) String smartClassId) {

        log.info("***********CampusController.getCampusClass******apiVersion:{},smartGradeId:{},orgId", apiVersion, smartClassId, orgId);

        try {

            Map<String, Object> params = new HashMap<>();
            params.put("smartClassId", smartClassId);
            params.put("orgId", orgId);
            ClassInfo classInfo = classInfoService.getByMapParams(params);
            ClassInfoDto classInfoDto = null;
            if (null != classInfo) {
                classInfoDto = new ClassInfoDto();
                BeanUtils.copyProperties(classInfo, classInfoDto);
            }

            return new ResultDTO<>(classInfoDto);

        } catch (Exception e) {
            log.error("***********CampusController.getCampusClass******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "通过学校ID和用户ID查询班级信息")
    @RequestMapping(value = "/getCampusClassByUserId", method = RequestMethod.GET)
    public ResultDTO<ClassInfoDto> getCampusClassByUserId(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId
    ) {
        log.info("***********CampusController.getCampusClassByUserId******apiVersion:{},userId:{},smartOrgId:{}", apiVersion, userId, orgId);

        ClassInfoDto classInfoDto = null;
        try {
            Map<String, Object> params = new HashMap<>();

            params.put("masterId", userId);
            params.put("orgId", orgId);
            ClassInfo classInfo = classInfoService.getByMapParams(params);

            if (null != classInfo) {


                classInfoDto = new ClassInfoDto();
                BeanUtils.copyProperties(classInfo, classInfoDto);
            }

            return new ResultDTO<>(classInfoDto);
        } catch (Exception e) {
            log.error("***********CampusController.getCampusClassByUserId******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);

        }

    }

    @ApiOperation(value = "新增班级")
    @RequestMapping(value = "/addCampusClass", method = RequestMethod.POST)
    public ResultDTO<Long> addCampusClass(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "班级", required = true) @RequestBody ClassInfoDto classInfoDto) {

        log.info("***********CampusController.addCampusClass******apiVersion:{},gradeDto:{}", apiVersion, classInfoDto);

        try {

            ClassInfo classInfo = new ClassInfo();
            BeanUtils.copyProperties(classInfoDto, classInfo);

            List<TeacherCourseVo> teacherCourseList = new ArrayList<TeacherCourseVo>();

            classInfoService.addClass(classInfo, teacherCourseList);

            return new ResultDTO<>(true);

        } catch (Exception e) {
            log.error("***********CampusController.addCampusClass******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "更新班级")
    @RequestMapping(value = "/updateCampusClass", method = RequestMethod.PUT)
    public ResultDTO<Long> updateCampusClass(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "班级", required = true) @RequestBody ClassInfoDto classInfoDto) {

        log.info("***********CampusController.updateCampusClass******apiVersion:{},gradeDto:{}", apiVersion, classInfoDto);

        if (classInfoDto.getId() == null || classInfoDto.getId() == 0) {
            return new ResultDTO<>(ErrorCode.PARAM_MISSING);
        }

        try {

            ClassInfo classInfo = new ClassInfo();
            BeanUtils.copyProperties(classInfoDto, classInfo);

            //2.0学校更新，只单纯更新班级
            if (originType == OriginTypeEnum.SELF_SUPPORT.getValue().intValue()) {
                classInfoService.update(classInfo);
            } else {
                Map<String, Object> paramsMap = new HashMap<>(1);
                paramsMap.put("orgId", classInfoDto.getOrgId());
                paramsMap.put("classId", classInfoDto.getId());
                List<TeacherCourse> teacherCourseList = teacherCourseService.getListByMapParams(paramsMap);
                List<TeacherCourseVo> teacherCourseVoList = new ArrayList<>(teacherCourseList.size());
                for (TeacherCourse teacherCourse : teacherCourseList) {
                    TeacherCourseVo teacherCourseVo = new TeacherCourseVo();
                    BeanUtils.copyProperties(teacherCourse, teacherCourseVo);
                    teacherCourseVoList.add(teacherCourseVo);
                }

                classInfoService.update(classInfo, teacherCourseVoList, true);
            }

            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********CampusController.updateCampusClass******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "删除班级")
    @RequestMapping(value = "/deleteCampusClass", method = RequestMethod.PUT)
    public ResultDTO<Long> deleteClass(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "班级ID", required = true) @RequestParam(name = "id", required = true) Long id) {

        log.info("***********CampusController.deleteCampusClass******apiVersion:{},id:{}", apiVersion, id);

        if (id == null) {
            return new ResultDTO<>(ErrorCode.PARAM_MISSING);
        }

        try {
            List<Long> classList = new ArrayList<>();
            classList.add(id);
            classInfoService.delete(classList, "系统管理员");

            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********CampusController.deleteCampusClass******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "查询部门")
    @RequestMapping(value = "/getCampusStructure", method = RequestMethod.GET)
    public ResultDTO<OrgStructureDto> getCampusStructure(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "智慧校园部门ID", required = true) @RequestParam(name = "smartStructureId", required = true) String smartStructureId) {

        log.info("***********CampusController.getCampusStructure******apiVersion:{},smartGradeId:{}", apiVersion, smartStructureId);

        try {

            Map<String, Object> params = new HashMap<>();
            params.put("smartStructureId", smartStructureId);

            OrgStructure orgStructure = orgStructureService.getByMapParams(params);
            OrgStructureDto structureDto = null;
            if (null != orgStructure) {
                structureDto = new OrgStructureDto();
                BeanUtils.copyProperties(orgStructure, structureDto);
            }

            return new ResultDTO<OrgStructureDto>(structureDto);

        } catch (Exception e) {
            log.error("***********CampusController.getCampusStructure******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation("新增组织架构")
    @RequestMapping(value = "/addCampusStructure", method = RequestMethod.POST)
    public ResultDTO addCampusStructure(
            @ApiParam(value = "接口版本", required = true, defaultValue = "v1") @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "部门", required = true) @RequestBody OrgStructureDto structureDto) {
        log.info("***********CampusController.addCampusStructure******apiVersion:{},structureDto", apiVersion, structureDto);

        try {
            OrgStructure orgStructure = new OrgStructure();
            orgStructure.setOrgId(structureDto.getOrgId());
            orgStructure.setParentId(structureDto.getParentId());
            orgStructure.setName(structureDto.getName());
            orgStructure.setType(structureDto.getType());
            orgStructure.setSmartStructureId(structureDto.getSmartStructureId());
            orgStructure.setStatus(true);
            orgStructure.setCreateBy("超级管理员");
            orgStructure.setUpdateBy("超级管理员");
            this.structureService.insert(orgStructure);

            return new ResultDTO(true);

        } catch (Exception e) {
            e.printStackTrace();
            log.error("CampusController.addCampusStructure**增加自定义组织异常", e);
            return new ResultDTO(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation("修改组织架构")
    @RequestMapping(value = "/updateCampusStructure", method = RequestMethod.PUT)
    public ResultDTO updateCampusStructure(
            @ApiParam(value = "接口版本", required = true, defaultValue = "v1") @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "部门", required = true) @RequestBody OrgStructureDto structureDto) {
        log.info("***********CampusController.updateCampusStructure******apiVersion:{},structureDto:{}", apiVersion, structureDto);

        try {

            if (structureDto.getId() == null || structureDto.getId() == 0) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }

            OrgStructure orgStructure = new OrgStructure();
            orgStructure.setId(structureDto.getId());
            orgStructure.setOrgId(structureDto.getOrgId());
            orgStructure.setName(structureDto.getName());
            orgStructure.setUpdateBy("超级管理员");
            this.structureService.update(orgStructure);

            return new ResultDTO();

        } catch (Exception e) {
            e.printStackTrace();
            log.error("CampusController.updateCampusStructure**修改组织异常", e);
            return new ResultDTO(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation("删除组织架构")
    @RequestMapping(value = "/deleteCampusStructure", method = RequestMethod.DELETE)
    public ResultDTO deleteCampusStructure(
            @ApiParam(value = "接口版本", required = true, defaultValue = "v1") @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "组织架构ID", required = true) @RequestParam(name = "id", required = true) Long id) {
        log.info("***********CampusController.deleteCampusStructure******apiVersion:{},structureId:{}", apiVersion, id);

        try {

            if (null == orgId || null == id) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }

            this.structureService.deleteOrgStructureBatch(id, orgId);

            return new ResultDTO();

        } catch (Exception e) {
            e.printStackTrace();
            log.error("CampusController.deleteCampusStructure**删除组织异常", e);
            return new ResultDTO(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "新增学生")
    @RequestMapping(value = "/addCampusStudent", method = RequestMethod.POST)
    public ResultDTO addCampusStudent(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @RequestBody StudentOpenDto studentOpenDto) {
        log.info("***********CampusController.addCampusStudent******...apiVersion:{},Student:{}", apiVersion, studentOpenDto);
        StudentManageEditVo studentManageEditVo = new StudentManageEditVo();
        BeanUtils.copyProperties(studentOpenDto, studentManageEditVo);

        StudentInfoDto studentInfoDto = studentManageEditVo.getStudentInfoDto();

        try {
            //检查是否已存在
            if (studentInfoDto.getUserId() != null && studentInfoDto.getUserId() != 0) {
                Map<String, Object> params = new HashMap<>(2);
                params.put("orgId", studentInfoDto.getOrgId());
                params.put("userId", studentInfoDto.getUserId());

                List<Student> exists = studentService.getListByMapParams(params);
                if (exists != null && !exists.isEmpty()) {
                    return new ResultDTO(ErrorCode.STUDENT_EXISTS);
                }
            }

            //检查学号卡号
            if (studentInfoDto.getCardNo() != null) {
                JSONArray jsonArray = JSON.parseArray(JSON.toJSONString(studentInfoDto.getCardNo()));

                for (Object o : jsonArray) {
                    ErrorCode errorCode = userService.checkMobileErrorCode(null, o.toString(), studentInfoDto.getStudentNo(), null,
                            RoleTypeEnum.STUDENT.getValue(), studentInfoDto.getOrgId(),null);
                    if (errorCode != null) {
                        return new ResultDTO(errorCode);
                    }
                }
            }

            checkHeadImg(studentInfoDto, false);

            studentService.insert(studentManageEditVo, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), true,true);
            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********CampusController.addCampusStudent******", e);
            return new ResultDTO<>(false);
        }
    }

    /**
     * 检查头像
     */
    private void checkHeadImg(StudentInfoDto studentInfoDto, boolean isUpdate) {
        if (StringUtil.isEmptyIgnoreBlank(studentInfoDto.getHeadImgUrl())) {
            isUpdate = false;
        }

        //若不是更新且无头像，使用默认头像
        if (!isUpdate && StringUtil.isNullOrBlank(studentInfoDto.getHeadImgUrl())) {
            studentInfoDto.setHeadImgUrl("女".equals(studentInfoDto.getSex()) ? BasicConstants.DEFAULT_HEADIMG_STUDENT_FEMALE :
                    BasicConstants.DEFAULT_HEADIMG_STUDENT_MALE);
            //若原头像为男性默认头像且修改性别为女，切换为女头像
        } else if (studentInfoDto.getHeadImgUrl().equals(BasicConstants.DEFAULT_HEADIMG_STUDENT_MALE)
                && "女".equals(studentInfoDto.getSex())) {
            studentInfoDto.setHeadImgUrl(BasicConstants.DEFAULT_HEADIMG_STUDENT_FEMALE);
            //若原头像为女性默认头像且修改性别为男，切换为男头像
        } else if (studentInfoDto.getHeadImgUrl().equals(BasicConstants.DEFAULT_HEADIMG_STUDENT_FEMALE)
                && "男".equals(studentInfoDto.getSex())) {
            studentInfoDto.setHeadImgUrl(BasicConstants.DEFAULT_HEADIMG_STUDENT_MALE);
        }
    }


    @ApiOperation(value = "修改学生")
    @RequestMapping(value = "/updateCampusStudent", method = RequestMethod.PUT)
    public ResultDTO updateCampusStudent(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @RequestBody StudentOpenDto studentOpenDto) {
        log.info("***********CampusController.updateCampusStudent******...apiVersion:{},Student:{}", apiVersion, studentOpenDto);
        StudentManageEditVo studentManageEditVo = new StudentManageEditVo();
        BeanUtils.copyProperties(studentOpenDto, studentManageEditVo);

        StudentInfoDto studentInfoDto = studentManageEditVo.getStudentInfoDto();

        try {
            List<FamilyInfoDto> familyInfoList = studentManageEditVo.getFamilyInfoList();
            if (familyInfoList != null && !familyInfoList.isEmpty()) {
                for (FamilyInfoDto familyInfoDto : familyInfoList) {
                    if (familyInfoDto == null || familyInfoDto.getUserId() == null) {
                        //如果用户ID为空，则根据手机号查询用户，如果存在，则补上用户ID
                        if (null == familyInfoDto.getUserId() && !StringUtils.isEmpty(familyInfoDto.getMobile())) {
                            User user = userService.getUserByMobile(familyInfoDto.getMobile());
                            if (null != user) {
                                familyInfoDto.setUserId(user.getId());
                            }
                        }
                        continue;
                    }
                    //TODO 后台暂不支持修改手机
                    familyInfoDto.setMobile(null);
                }
            }

            checkHeadImg(studentInfoDto, true);

            studentService.update(studentManageEditVo, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), true);
            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********CampusController.updateCampusStudent******", e);
            return new ResultDTO<>(false);
        }
    }


    @ApiOperation(value = "删除学生")
    @RequestMapping(value = "/deleteCampusStudent", method = RequestMethod.DELETE)
    public ResultDTO deleteCampusStudent(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "学生id", required = true) @RequestParam(name = "id", required = true) List<Long> ids) {
        log.info("***********CampusController.deleteCampusStudent******...apiVersion:{},Student:{}", apiVersion, Arrays.toString(ids != null ? ids.toArray() : new Object[0]));
        try {
            return studentService.deleteStudent(ids, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), SubmitEnum.SUBMIT.getValue());
        } catch (Exception e) {
            log.error("***********CampusController.deleteCampusStudent******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "查询学生详情")
    @RequestMapping(value = "/getCampusStudentInfoById", method = RequestMethod.GET)
    public ResultDTO<Map<String, Object>> getCampusStudentInfoById(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = false) @RequestParam(name = "orgId", required = false) Long orgId,
            @ApiParam(value = "智慧校园用户ID", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId,
            @ApiParam(value = "学生手机号", defaultValue = "13000004444", required = false) @RequestParam(name = "mobile", required = false) String mobile) {
        log.info("***********CampusController.getCampusStudentInfoById******...apiVersion:{},originType:{},originType:{},originType:{}", apiVersion, originType, smartUserId, mobile);

        try {
            Map<String, Object> params = new HashMap<>(1);
            Map<String, Object> studentInfoDtoMap = new HashMap<>(2);

            Boolean flag = true;
            StudentInfoDto studentInfoDto = null;
            if (StringUtil.isNotEmptyIgnoreBlank(mobile)) {
                params.put("mobile", mobile);
                params.put("orgId", orgId);
                //通过手机号查询用户
                studentInfoDto = studentService.getStudentInfoByMapParams(params);

                if (null == studentInfoDto && StringUtil.isNotEmptyIgnoreBlank(smartUserId)) {
                    Map<String, Object> smartUserIdParams = new HashMap<>(1);
                    smartUserIdParams.put("orgId", orgId);
                    smartUserIdParams.put("smartUserId", smartUserId);
                    studentInfoDto = studentService.getStudentInfoByMapParams(smartUserIdParams);

                    //如果学生表没数据,用户表有数据,返回此用户手机号被使用
                    if (null == studentInfoDto) {
                        User userByMobile = userService.getUserByMobile(mobile);

                        if (null != userByMobile) {
                            flag = false;
                        }
                    }
                }
            } else {
                params.put("orgId", orgId);
                params.put("smartUserId", smartUserId);
                studentInfoDto = studentService.getStudentInfoByMapParams(params);
            }

            studentInfoDtoMap.put("studentInfoDto", studentInfoDto);
            studentInfoDtoMap.put("flag", flag);
            return new ResultDTO<>(studentInfoDtoMap);
        } catch (Exception e) {
            log.error("***********CampusController.getCampusStudentInfoById******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "查询学生信息")
    @RequestMapping(value = "/getCampusStudentBySmartUserId", method = RequestMethod.GET)
    public ResultDTO<List<StudentInfoDto>> getCampusStudentBySmartUserId(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = false) @RequestParam(name = "orgId", required = false) Long orgId,
            @ApiParam(value = "智慧校园用户ID", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId) {
        log.info("***********CampusController.getCampusStudentBySmartUserId******originType:{},originType:{},originType:{}", originType, smartUserId);

        try {

            Map<String, Object> params = new HashMap<>(3);
            params.put("orgId", orgId);
            params.put("smartUserId", smartUserId);
            params.put("status", CommonStatusEnum.STARTSTATUS.getValue());
            List<Student> studentList = studentService.getListByMapParams(params);

            ArrayList<StudentInfoDto> studentInfoDtoList = new ArrayList<>();
            StudentInfoDto studentInfoDto = new StudentInfoDto();
            if (CollectionUtils.isNotEmpty(studentList)) {
                //查下名称
                Long userId = studentList.get(0).getUserId();
                User user = userService.getByPrimaryKey(userId);
                studentList.forEach(
                        (e) -> {
                            BeanUtils.copyProperties(e, studentInfoDto);
                            if(null!=user) {
                                studentInfoDto.setName(user.getName());
                                studentInfoDto.setMobile(user.getMobile());
                            }
                            studentInfoDtoList.add(studentInfoDto);
                        });
            }

            return new ResultDTO<>(studentInfoDtoList);

        } catch (Exception e) {
            log.error("***********CampusController.getCampusStudentBySmartUserId******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "新增家长")
    @RequestMapping(value = "/addCampusFamily", method = RequestMethod.POST)
    public ResultDTO addCampusFamily(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @RequestBody FamilyOpenDto familyOpenDto) {
        log.info("***********CampusController.addCampusFamily******...apiVersion:{},Family:{}", apiVersion, familyOpenDto);

        try {

            FamilyManageEditVo familyManageEditVo = new FamilyManageEditVo();
            BeanUtils.copyProperties(familyOpenDto, familyManageEditVo);
            FamilyInfoDto familyInfoDto = familyManageEditVo.getFamilyInfoDto();

            List<StudentInfoDto> studentInfoDtoList = familyManageEditVo.getStudentInfoDtoList();
            if (familyInfoDto == null || StringUtil.isNullOrBlank(familyInfoDto.getMobile())
                    || studentInfoDtoList == null || studentInfoDtoList.isEmpty()) {

                ImportLog importLog = new ImportLog();
                importLog.setRemark(JSONObject.toJSONString(familyOpenDto));
                importLogService.insert(importLog);

                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }
            //设置通讯录默认显示
            familyInfoDto.setShowAddressBook(true);

            familyService.insert(familyManageEditVo, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), true);
            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********CampusController.addCampusFamily******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "修改家长")
    @RequestMapping(value = "/updateCampusFamily", method = RequestMethod.PUT)
    public ResultDTO updateCampusFamily(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @RequestBody FamilyInfoDto familyInfoDto) {
        log.info("***********CampusController.updateCampusFamily******...apiVersion:{},Family:{}", apiVersion, familyInfoDto);

        Organization organization = new Organization();
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> stringObjectMap = new HashMap<>();
        try {
            //查询smartOrderId
            organization = organizationService.getByPrimaryKey(familyInfoDto.getOrgId());

            //通过family表ID查询记录,有就修改family信息,没有就新增
            Map<String, Object> params = new HashMap<>(3);
            params.put("mobile", familyInfoDto.getMobile());
            params.put("studentId", familyInfoDto.getStudentUserId());
            params.put("status", CommonStatusEnum.STARTSTATUS.getValue());
            Family family = familyService.getByMapParams(params);

            //通过学生ID查询学生是否有智慧校园微信ID
            familyInfoDto.setShowAddressBook(true);
            User user = userService.getByPrimaryKey(familyInfoDto.getStudentUserId());

            if (null != family) {

                stringObjectMap.put("FamilyInfoDto", familyInfoDto);
                list.add(stringObjectMap);
                //统计家长修改的次数
                String countControllerNum = countUpdateFamily("CampusController", "countUpdateFamily", organization.getSmartOrgId(), familyInfoDto.getSmartUserId());
                saveUserInfoRedis(countControllerNum, list);

                familyService.updateFamily(familyInfoDto, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), true);
            } else {

                //新增家长时,需要家长进入对应的群
                StudentManageEditVo studentManageEditVo = new StudentManageEditVo();

                List<FamilyInfoDto> familyInfoList = new ArrayList<>();
                familyInfoList.add(familyInfoDto);

                //查询学生
                Map<String, Object> studentParams = new HashMap<String, Object>();
                studentParams.put("orgId", familyInfoDto.getOrgId());
                studentParams.put("userId", familyInfoDto.getStudentUserId());
                StudentInfoDto studentInfo = studentService.getStudentInfoByMapParams(studentParams);
                studentInfo.setSmartWxUserId(user.getSmartWxUserId());
                studentInfo.setIsSmartSubscribe(user.getIsSmartSubscribe());
                studentManageEditVo.setStudentInfoDto(studentInfo);
                studentManageEditVo.setFamilyInfoList(familyInfoList);
                studentService.insert(studentManageEditVo, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), true,true);

                //统计新增家长学生关系的次数
                stringObjectMap.put("StudentManageEditVo", studentManageEditVo);
                list.add(stringObjectMap);
                String countControllerNum = countInsertFamily("CampusController", "countInsertFamily", organization.getSmartOrgId(), familyInfoDto.getSmartUserId());
                saveUserInfoRedis(countControllerNum, list);
            }
            return new ResultDTO<>(true);
        } catch (Exception e) {
            stringObjectMap.put("familyInfoDto", familyInfoDto);
            stringObjectMap.put("ErrorCode", null);
            list.add(stringObjectMap);
            String errorFamily = errorFamily("CampusController", "errorFamily", organization.getSmartOrgId(), familyInfoDto.getSmartUserId());
            saveUserInfoRedis(errorFamily, stringObjectMap);
            log.error("***********CampusController.updateCampusFamily******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "删除家长")
    @RequestMapping(value = "/deleteCampusFamily", method = RequestMethod.DELETE)
    public ResultDTO<Object> deleteCampusFamily(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "家长表id", required = true) @RequestParam(name = "id", required = true) List<Long> ids) {
        log.info("***********CampusController.deleteCampusFamily******...apiVersion:{},ids:{}", apiVersion, Arrays.toString(ids.toArray()));

        try {
            return familyService.deleteFamily(ids, SysRoleTypeEnum.SUPER_ADMIN.getDesc());
        } catch (Exception e) {
            log.error("***********CampusController.deleteCampusFamily******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "通过smartUserId查询家长详情")
    @RequestMapping(value = "/getCampusFamilyInfoById", method = RequestMethod.GET)
    public ResultDTO<FamilyInfoDto> getCampusFamilyInfoById(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "家长表id", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId,
            @ApiParam(value = "学生id", required = false) @RequestParam(name = "studentId", required = false) Long studentId
    ) {
        log.info("***********CampusController.getCampusFamilyInfoById******...apiVersion:{},Employee:{}", apiVersion, smartUserId);
        try {
            Map<String, Object> params = new HashMap<>(3);
            params.put("smartUserId", smartUserId);
            params.put("studentId", studentId);
            params.put("status", CommonStatusEnum.STARTSTATUS.getValue());
            FamilyInfoDto familyInfoDto = getFamilyInfoDto(params);
            return new ResultDTO<>(familyInfoDto);
        } catch (Exception e) {
            log.error("***********CampusController.getCampusFamilyInfoById******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "查询家长详情列表")
    @RequestMapping(value = "/getCampusFamilyInfoBySmartUserId", method = RequestMethod.GET)
    public ResultDTO<List<FamilyInfoDto>> getCampusFamilyInfoBySmartUserId(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = true) @RequestParam(name = "orgId", required = false) Long orgId,
            @ApiParam(value = "家长表id", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId)
    {
        log.info("***********CampusController.getCampusFamilyInfoBySmartUserId******orgId:{},smartUserId:{}", orgId, smartUserId);
        try {
            Map<String, Object> params = new HashMap<>(3);
            params.put("orgId", orgId);
            params.put("smartUserId", smartUserId);
            params.put("status", CommonStatusEnum.STARTSTATUS.getValue());
            List<Family> familyList = familyService.getListByMapParams(params);

            ArrayList<FamilyInfoDto> familyInfoDtoList = new ArrayList<>();
            if (CollectionUtils.isNotEmpty(familyList)) {
                //查下名称
                Long userId = familyList.get(0).getUserId();
                User user = userService.getByPrimaryKey(userId);
                familyList.forEach(
                        (e) -> {
                            FamilyInfoDto familyInfoDto = new FamilyInfoDto();
                            BeanUtils.copyProperties(e, familyInfoDto);
                            if(null!=user) {
                                familyInfoDto.setName(user.getName());
                                familyInfoDto.setMobile(user.getMobile());
                            }
                            familyInfoDtoList.add(familyInfoDto);
                        });
            }
            return new ResultDTO<>(familyInfoDtoList);
        } catch (Exception e) {
            log.error("***********CampusController.getCampusFamilyInfoById******", e);
            return new ResultDTO<>(false);
        }
    }


    @ApiOperation(value = "通过手机号查询家长详情")
    @RequestMapping(value = "/getCampusFamilyInfoByMobile", method = RequestMethod.GET)
    public ResultDTO<FamilyInfoDto> getCampusFamilyInfoByMobile(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "家长表手机号", required = true) @RequestParam(name = "mobile", required = true) String mobile,
            @ApiParam(value = "学生id", required = false) @RequestParam(name = "studentId", required = false) Long studentId
    ) {
        log.info("***********CampusController.getCampusFamilyInfoByMobile******...apiVersion:{},orgId:{},mobile:{},studentId:{}", apiVersion, orgId, mobile, studentId);
        try {
            Map<String, Object> params = new HashMap<>(3);
            params.put("orgId", orgId);
            params.put("mobile", mobile);
            params.put("studentId", studentId);
            params.put("status", CommonStatusEnum.STARTSTATUS.getValue());
            FamilyInfoDto familyInfoDto = getFamilyInfoDto(params);
            return new ResultDTO<>(familyInfoDto);
        } catch (Exception e) {
            log.error("***********CampusController.getCampusFamilyInfoByMobile******", e);
            return new ResultDTO<>(false);
        }
    }

    public FamilyInfoDto getFamilyInfoDto(Map<String, Object> params) throws Exception {
        Family family = familyService.getByMapParams(params);

        FamilyInfoDto familyInfoDto = new FamilyInfoDto();
        if (null != family) {
            BeanUtils.copyProperties(family, familyInfoDto);
            User user = userService.getByPrimaryKey(family.getUserId());
            familyInfoDto.setHeadImgUrl(user.getHeadImgUrl());
        }
        return familyInfoDto;
    }


    @ApiOperation(value = "智慧校园人脸新增或删除接口")
    @RequestMapping(value = "/saveWitUserFace", method = RequestMethod.POST)
    public ResultDTO<Object> saveWitUserFace(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "人脸URL", required = true) @RequestParam(name = "picUrl", required = true) String picUrl,
            @ApiParam(value = "智慧校园学校ID", required = true) @RequestParam(name = "smartSchoolId", required = true) String smartSchoolId,
            @ApiParam(value = "智慧校园用户ID", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId,
            @ApiParam(value = "是否删除:1删除,0不删除", required = true) @RequestParam(name = "isDelete", required = true) String isDelete,
            @ApiParam(value = "用户类型:1学生2老师3家长", required = true) @RequestParam(name = "smartUserType", required = true) Short smartUserType
    ) {
        log.info("***********CampusController.saveWitUserFace******...apiVersion:{},picUrl:{},smartSchoolId:{},smartUserId:{},isDelete:{},smartUserType:{}", apiVersion, picUrl, smartSchoolId, smartUserId, isDelete, smartUserType);
        try {
            //查询
            Map<String, Object> params = new HashMap<>();
            params.put("smartOrgId", smartSchoolId);

            Organization organization = organizationService.getByMapParams(params);
            if (null != organization) {

                params.put("smartUserId", smartUserId);
                params.put("status", CommonStatusEnum.STARTSTATUS.getValue());
                params.put("orgId", organization.getId());

                switch (smartUserType) {
                    case 1:
                        Student student = studentService.getByMapParams(params);
                        if (null != student) {
                            addWitCampusUserFace(student.getUserId(), student.getOrgId(), picUrl, isDelete);
                        }
                        break;
                    case 2:
                        Employee employee = employeeService.getByMapParams(params);
                        if (null != employee) {
                            addWitCampusUserFace(employee.getUserId(), employee.getOrgId(), picUrl, isDelete);
                        }
                        break;
                    case 3:
                        List<Family> family = familyService.getListByMapParams(params);
                        if (null != family && family.size() > 0) {
                            addWitCampusUserFace(family.get(0).getUserId(), family.get(0).getOrgId(), picUrl, isDelete);
                        }
                        break;
                    default:
                        break;

                }
            }

            return new ResultDTO<>();
        } catch (Exception e) {
            log.error("***********CampusController.saveWitUserFace******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "查询员工详情")
    @RequestMapping(value = "/getCampusEmployeeById", method = RequestMethod.GET)
    public ResultDTO<EmployeeInfoDto> getCampusEmployeeById(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = false) @RequestParam(name = "orgId", required = false) Long orgId,
            @ApiParam(value = "员工id", required = true) @RequestParam(name = "id", required = true) String smartUserId) {
        log.info("***********CampusController.getCampusEmployeeById******...orgId:{},Employee:{}", orgId, smartUserId);
        try {

            Map<String, Object> params = new HashMap<>(3);
            params.put("orgId", orgId);
            params.put("smartUserId", smartUserId);
            EmployeeInfoDto employeeInfoDto = getEmployeeInfoDto(params);
            return new ResultDTO<EmployeeInfoDto>(employeeInfoDto);
        } catch (Exception e) {
            log.error("***********CampusController.getCampusEmployeeById******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "查询员工列表")
    @RequestMapping(value = "/getCampusEmployeeListById", method = RequestMethod.GET)
    public ResultDTO<List<EmployeeInfoDto>> getCampusEmployeeListById(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = false) @RequestParam(name = "orgId", required = false) Long orgId,
            @ApiParam(value = "员工id", required = true) @RequestParam(name = "id", required = true) String smartUserId) {
        log.info("***********CampusController.getCampusEmployeeListById******...orgId:{},smartUserId:{}", orgId, smartUserId);
        try {

            Map<String, Object> params = new HashMap<>(3);
            params.put("smartUserId", smartUserId);
            List<Employee> employeeInfoList = employeeService.getListByMapParams(params);

            ArrayList<EmployeeInfoDto> employeeList = new ArrayList<>();
            for(Employee employee : employeeInfoList)
            {
                EmployeeInfoDto employeeInfoDto = new EmployeeInfoDto();
                BeanUtils.copyProperties(employee,employeeInfoDto);
                employeeList.add(employeeInfoDto);
            }

            return new ResultDTO<List<EmployeeInfoDto>>(employeeList);


        } catch (Exception e) {
            log.error("***********CampusController.getCampusEmployeeListById******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "查询员工详情")
    @RequestMapping(value = "/getCampusEmployeeByMobile", method = RequestMethod.GET)
    public ResultDTO<EmployeeInfoDto> getCampusEmployeeByMobile(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "手机号", required = true) @RequestParam(name = "mobile", required = true) String mobile) {
        log.info("***********CampusController.getCampusEmployeeByMobile******orgId:{},mobile:{}", orgId, mobile);
        try {

            Map<String, Object> params = new HashMap<>(3);
            params.put("orgId", orgId);
            params.put("mobile", mobile);
            EmployeeInfoDto employeeInfoDto = getEmployeeInfoDto(params);
            return new ResultDTO<>(employeeInfoDto);
        } catch (Exception e) {
            log.error("***********CampusController.getCampusEmployeeByMobile******", e);
            return new ResultDTO<>(false);
        }
    }

    public EmployeeInfoDto getEmployeeInfoDto(Map<String, Object> params) throws Exception {
        Employee employee = employeeService.getByMapParams(params);
        EmployeeInfoDto employeeInfoDto = new EmployeeInfoDto();
        if (null != employee) {
            BeanUtils.copyProperties(employee, employeeInfoDto);
        }
        return employeeInfoDto;
    }

    @ApiOperation(value = "新增老师")
    @RequestMapping(value = "/addCampusTeacher", method = RequestMethod.POST)
    public ResultDTO<EmployeeInfoDto> addCampusTeacher(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @RequestBody EmployeeInfoDto employeeInfoDto) {
        log.info("***********TeacherManageController.addCampusTeacher******...apiVersion:{},Employee:{}", apiVersion, employeeInfoDto);
        try {

            //判断当前学校学校是否有已有该老师用户
            if (employeeInfoDto.getUserId() != null && employeeInfoDto.getUserId() != 0) {
                Map<String, Object> params = new HashMap<>(2);
                params.put("orgId", employeeInfoDto.getOrgId());
                params.put("userId", employeeInfoDto.getUserId());
                List<TeacherManageVo> allTeacherManageList = teacherManageService.getAllTeacherManageList(params);
                if (allTeacherManageList != null && !allTeacherManageList.isEmpty()) {
                    return new ResultDTO<>(ErrorCode.EMPLOYEE_EXISTS);
                }
            }

            Long insert = teacherManageService.insertTeacher(employeeInfoDto, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), true,true);

            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********TeacherManageController.addTeacher******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "修改老师")
    @RequestMapping(value = "/updateCampusTeacher", method = RequestMethod.PUT)
    public ResultDTO<EmployeeInfoDto> updateCampusTeacher(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @RequestBody EmployeeInfoDto employeeInfoDto) {
        log.info("***********TeacherManageController.updateTeacher******...apiVersion:{},Employee:{}", apiVersion, employeeInfoDto);
        try {
            //后台不会修改手机号
            ErrorCode result = userService.checkMobileErrorCode(null, employeeInfoDto.getCardNo(), employeeInfoDto.getJobNo(),
                    employeeInfoDto.getUserId(), RoleTypeEnum.TEACHER.getValue(), employeeInfoDto.getOrgId(), employeeInfoDto.getAccount(),null);
            if (result != null) {
                return new ResultDTO<>(result);
            }

            //通过手机号获取用户信息
            User userByMobile = userService.getUserByMobile(employeeInfoDto.getMobile());

            if (null != userByMobile) {
                employeeInfoDto.setUserId(userByMobile.getId());
            }

            //通过smartuserid获取用户ID
            Map<String, Object> params = new HashMap<>(1);
            params.put("mobile", employeeInfoDto.getMobile());
            params.put("orgId", employeeInfoDto.getOrgId());
            Employee employee = employeeService.getByMapParams(params);

            if (null == employee) {
                teacherManageService.insertTeacher(employeeInfoDto, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), true,true);
            } else {
                return teacherManageService.updateTeacher(employeeInfoDto, SysRoleTypeEnum.SUPER_ADMIN.getDesc(), true, false);
            }
            return new ResultDTO<>(true);
        } catch (Exception e) {
            log.error("***********TeacherManageController.updateCampusTeacher******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "删除老师")
    @RequestMapping(value = "/deleteCampusTeacher", method = RequestMethod.DELETE)
    public ResultDTO deleteCampusTeacher(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "老师表id", required = true) @RequestParam(name = "id", required = true) List<Long> ids) {
        log.info("***********TeacherManageController.deleteCampusTeacher******...apiVersion:{},ids:{}", apiVersion, Arrays.toString(ids != null ? ids.toArray() : new Object[0]));

        try {
            if (ids == null || ids.isEmpty()) {
                return new ResultDTO<>();
            }

            return teacherManageService.deleteTeacher(ids, SysRoleTypeEnum.SUPER_ADMIN.getDesc());
            /*ClassInfoDto errorClassInfo = teacherManageService.delete(ids, SysRoleTypeEnum.SUPER_ADMIN.getDesc());
            if (errorClassInfo != null) {
                ResultDTO<ClassInfoDto> resultDTO = new ResultDTO<>(ErrorCode.TEACHER_IS_MASTER);
                resultDTO.setData(errorClassInfo);
                return resultDTO;
            }*/

            //return new ResultDTO<>();
        } catch (Exception e) {
            log.error("***********TeacherManageController.deleteCampusTeacher******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "新增用户与组织关系")
    @RequestMapping(value = "/addCampusStructureUser", method = RequestMethod.POST)
    public ResultDTO addCampusStructureUser(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "组织信息ID", required = true) @RequestParam(name = "structureId", required = true) Long structureId) {
        log.info("***********CampusController.addCampusStructureUser******,orgId:{},userId:{},structureId:{}", orgId, userId, structureId);
        try {
            if (orgId == null || null == userId || null == structureId) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }
            OrgStructureUser orgStructureUser = new OrgStructureUser();
            orgStructureUser.setOrgId(orgId);
            orgStructureUser.setUserId(userId);
            orgStructureUser.setStructureId(structureId);
            orgStructureUserService.insert(orgStructureUser);
            return new ResultDTO<>();
        } catch (Exception e) {
            log.error("***********CampusController.addCampusStructureUser******", e);
            return new ResultDTO<>(false);
        }
    }


    @ApiOperation(value = "删除用户与组织关系")
    @RequestMapping(value = "/deleteCampusStructureUser", method = RequestMethod.POST)
    public ResultDTO deleteCampusStructureUser(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "用户组织架构关系表ID", required = true) @RequestParam(name = "orgStructureUserId", required = true) Long orgStructureUserId) {
        log.info("***********CampusController.deleteCampusStructureUser******,orgStructureUserId:{}", orgStructureUserId);
        try {
            if (orgStructureUserId == null) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }
            orgStructureUserService.deleteByPrimaryKey(orgStructureUserId);
            return new ResultDTO<>();
        } catch (Exception e) {
            log.error("***********CampusController.deleteCampusStructureUser******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "查询用户与组织关系")
    @RequestMapping(value = "/getCampusStructureUser", method = RequestMethod.POST)
    public ResultDTO<OrgStructureUserDto> getCampusStructureUser(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = false) @RequestParam(name = "orgId", required = false) Long orgId,
            @ApiParam(value = "用户ID", required = false) @RequestParam(name = "userId", required = false) Long userId,
            @ApiParam(value = "组织信息ID", required = false) @RequestParam(name = "structureId", required = false) Long structureId
    ) {
        log.info("***********CampusController.getCampusStructureUser******,orgId:{},userId:{},structureId:{}", orgId, userId, structureId);
        try {
            if (orgId == null || null == userId || null == structureId) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }

            Map<String, Object> params = new HashMap<>(3);
            params.put("orgId", orgId);
            params.put("userId", userId);
            params.put("structureId", structureId);
            OrgStructureUser orgStructureUser = orgStructureUserService.getByMapParams(params);
            OrgStructureUserDto orgStructureUserDto = new OrgStructureUserDto();
            BeanUtils.copyProperties(orgStructureUser, orgStructureUserDto);
            return new ResultDTO<>(orgStructureUserDto);

        } catch (Exception e) {
            log.error("***********CampusController.getCampusStructureUser******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "更新用户与组织关系")
    @RequestMapping(value = "/updateCampusStructureUser", method = RequestMethod.POST)
    public ResultDTO<OrgStructureUserDto> updateCampusStructureUser(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "用户组织架构关系表ID", required = true) @RequestParam(name = "orgStructureUserId", required = true) Long orgStructureUserId,
            @ApiParam(value = "组织ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "组织信息ID", required = true) @RequestParam(name = "structureId", required = true) Long structureId
    ) {
        log.info("***********CampusController.updateCampusStructureUser******,orgStructureUserId:{}orgId:{},userId:{},structureId:{}", orgStructureUserId, orgId, userId, structureId);
        try {
            if (orgId == null || null == userId || null == structureId) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }

            Map<String, Object> params = new HashMap<>(4);
            params.put("orgId", orgId);
            params.put("userId", userId);
            params.put("structureId", structureId);
            params.put("id", orgStructureUserId);
            orgStructureUserService.updateByPrimaryKeySelective(params);
            return new ResultDTO<>();

        } catch (Exception e) {
            log.error("***********CampusController.updateCampusStructureUser******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "IM自动建群")
    @RequestMapping(value = "/getCampusAutoGroupFeign", method = RequestMethod.POST)
    public ResultDTO<Object> getCampusAutoGroupFeign(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "班级ID", required = true) @RequestParam(name = "classId", required = true) Long classId,
            @ApiParam(value = "用户名称", required = true) @RequestParam(name = "userName", required = true) String userName
    ) {
        log.info("***********CampusController.getCampusAutoGroupFeign******,orgId:{},userId:{},classId:{},userName:{}", orgId, userId, classId, userName);
        try {
            if (orgId == null || null == userId || null == classId || null == userName) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }
            //新增班级后触发IM自动创群
            classInfoService.getAutoGroupFeign(RoleTypeEnum.TEACHER.getValue(), true, userId, userName, orgId, classId, null);
            return new ResultDTO<>();
        } catch (Exception e) {
            log.error("***********CampusController.getCampusAutoGroupFeign******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "新增任课教师")
    @RequestMapping(value = "/addCampusTeacherCourse", method = RequestMethod.POST)
    public ResultDTO addCampusTeacherCourse(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "负责人ID", required = true, defaultValue = "111") @RequestParam(name = "masterId", required = true) Long masterId,
            @ApiParam(value = "班级ID", required = true, defaultValue = "3") @RequestParam(name = "classId", required = true) Long classId,
            @ApiParam(value = "学校ID", required = true, defaultValue = "3") @RequestParam(name = "orgId", required = true) Long orgId
    ) {
        log.info("***********CampusController.addCampusTeacherCourse******apiVersion:{},masterId:{},classId:{}，courseName:{}",
                apiVersion, masterId, classId);
        try {
            if (masterId == null || classId == null) {
                return new ResultDTO(ErrorCode.PARAM_MISSING);
            }

            ClassInfo classInfo = classInfoService.getByPrimaryKey(classId);
            if (classInfo == null) {
                return new ResultDTO(ErrorCode.CLASS_NOT_EXISTS);
            }

            classInfoService.imTeacherCourse(masterId, classInfo, orgId, false);

            return new ResultDTO();
        } catch (Exception e) {
            log.error("***********CampusController.addCampusTeacherCourse******", e);
            return new ResultDTO(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "删除任课教师")
    @RequestMapping(value = "/deleteCampusTeacherCourse", method = RequestMethod.DELETE)
    public ResultDTO deleteCampusTeacherCourse(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "负责人ID", required = true, defaultValue = "111") @RequestParam(name = "masterId", required = true) Long masterId,
            @ApiParam(value = "班级ID", required = true, defaultValue = "3") @RequestParam(name = "classId", required = true) Long classId,
            @ApiParam(value = "学校ID", required = true, defaultValue = "3") @RequestParam(name = "orgId", required = true) Long orgId) {
        log.info("***********CampusController.deleteCampusTeacherCourse******apiVersion:{},originType:{},masterId:{},classId:{},orgId:{}", apiVersion, originType, masterId, classId, orgId);

        try {
            if (originType == null || masterId == null || classId == null || orgId == null) {
                return new ResultDTO(ErrorCode.PARAM_MISSING);
            }
            ClassInfo classInfo = classInfoService.getByPrimaryKey(classId);

            classInfoService.imTeacherCourse(masterId, classInfo, orgId, true);
            return new ResultDTO();
        } catch (Exception e) {
            log.error("***********CampusController.deleteCampusTeacherCourse******", e);
            return new ResultDTO(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "通过学校,班级,用户ID查询任课列表")
    @RequestMapping(value = "/getCampusTeacherCourseList", method = RequestMethod.GET)
    public ResultDTO<TeacherCourseDto> getCampusTeacherCourseList(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "负责人ID", required = true, defaultValue = "111") @RequestParam(name = "masterId", required = true) Long masterId,
            @ApiParam(value = "班级ID", required = true, defaultValue = "3") @RequestParam(name = "classId", required = true) Long classId,
            @ApiParam(value = "学校ID", required = true, defaultValue = "3") @RequestParam(name = "orgId", required = true) Long orgId
    ) {
        log.info("***********CampusController.getCampusTeacherCourseList******apiVersion:{},masterId:{},classId:{},orgId:{}", apiVersion, masterId, classId, orgId);

        try {
            if (masterId == null || classId == null || orgId == null) {
                return new ResultDTO(ErrorCode.PARAM_MISSING);
            }

            Map<String, Object> params = new HashMap<>(4);
            params.put("masterId", masterId);
            params.put("classId", classId);
            params.put("orgId", orgId);
            List<TeacherCourse> teacherCourseList = teacherCourseService.getListByMapParams(params);
            TeacherCourseDto teacherCourseDto = new TeacherCourseDto();
            if (null != teacherCourseList && teacherCourseList.size() > 0) {
                BeanUtils.copyProperties(teacherCourseList.get(0), teacherCourseDto);
            }
            return new ResultDTO<>(teacherCourseDto);
        } catch (Exception e) {
            log.error("***********CampusController.getCampusTeacherCourseList******", e);
            return new ResultDTO(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "学校配置推送")
    @RequestMapping(value = "/saveSchoolConfig", method = RequestMethod.POST)
    public ResultDTO<Object> saveSchoolConfig(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "学校配置推送") @RequestBody SmartWitSchoolConfig smartWitSchoolConfig
    ) {
        log.info("***********CampusController.saveSchoolConfig******apiVersion:{},smartOrgId:{}", apiVersion, smartWitSchoolConfig);

        try {
            if (StringUtil.isEmptyIgnoreBlank(smartWitSchoolConfig.getSchoolId())) {
                return new ResultDTO(ErrorCode.PARAM_MISSING);
            }

            Map<String, Object> params = new HashMap<>(4);
            params.put("smartOrgId", smartWitSchoolConfig.getSchoolId());
            Organization organization = organizationService.getByMapParams(params);

            UserDto userDt = new UserDto();
            userDt.setName(SysRoleTypeEnum.SUPER_ADMIN.getDesc());

            if (null != organization) {
                OrgServiceConfig orgServiceConfig = new OrgServiceConfig();
                orgServiceConfig.setOrgId(organization.getId());

                BeanUtils.copyProperties(smartWitSchoolConfig, orgServiceConfig);

                if (VIDIOSWITCH.contains(organization.getName())) {
                    orgServiceConfig.setVideoSwitch(false);
                }
                orgServiceConfigService.saveOrgServiceConfig(orgServiceConfig, userDt);
            }

            return new ResultDTO<>(organizationService.getByMapParams(params));
        } catch (Exception e) {
            log.error("***********CampusController.saveSchoolConfig******", e);
            return new ResultDTO(ErrorCode.SYSTEM_EXCEPTION);
        }

    }

    @ApiOperation(value = "查询岗位信息")
    @RequestMapping(value = "/getPositionInfo", method = RequestMethod.GET)
    public ResultDTO<PositionDto> getPositionInfo(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "岗位ID", required = true, defaultValue = "3") @RequestParam(name = "positionId", required = true) Long positionId
    ) {
        log.info("***********CampusController.getPositionInfo******apiVersion:{},positionId:{}", apiVersion, positionId);

        try {
            if (null == positionId) {
                return new ResultDTO(ErrorCode.PARAM_MISSING);
            }
            Position position = positionService.getByPrimaryKey(positionId);

            PositionDto positionDto = new PositionDto();
            BeanUtils.copyProperties(position, positionDto);

            return new ResultDTO<>(positionDto);
        } catch (Exception e) {
            log.error("***********CampusController.getPositionInfo******", e);
            return new ResultDTO(ErrorCode.SYSTEM_EXCEPTION);
        }

    }

    private void addWitCampusUserFace(Long userId, Long orgId, String picUrl, String isDelete) {
        try {
            log.info("********开始新增或者删除人脸********");

            if (isDelete.equals(CommonStatusEnum.STARTSTATUS.getValue().toString())) {
                List<YoutuFace> youtuFaceList = youTuService.selectFaceByuserCode(userId, orgId);
                if (null != youtuFaceList && youtuFaceList.size() > 0) {
                    for (YoutuFace youtuFace : youtuFaceList) {
                        webankService.modifyFace(youtuFace.getPersonId(), orgId,true,picUrl,null,null);
                    }
                }
            } else {
                Long accountId = null;
                ResultDTO<AccountDto> result = wxFeignService.getAccountByOrg(orgId);
                if (ResultDTO.checkSuccess(result) && result.getData() != null) {
                    accountId = result.getData().getId();
                }
                //防止重复导入
                if (!StringUtils.isEmpty(picUrl)) {
                    List<YoutuFace> youtuFaceList = youTuService.selectFaceByuserCode(userId, orgId);
                    if (null != youtuFaceList && youtuFaceList.size() > 0) {
                        for (YoutuFace youtuFace : youtuFaceList) {
                            if (null != youtuFace.getDevicePath() && youtuFace.getDevicePath().equals(picUrl)) {
                                log.info("----已存在personId={},webUrl={}的人脸----", youtuFace.getPersonId(), youtuFace.getWebUrl());
                                return;
                            }
                        }
                    }
                    //替换2.0迁移路径
                    String url = youTuService.changeUrl(picUrl);
                    webankService.addWeBankUserFace(url, UuIdUtil.getUserCodeByUUId(), orgId, accountId, userId, EntranceEnum.MINI.getValue(), null);

                    YoutuPerson youtuPerson = youTuService.getYoutuPerson(orgId, userId);
                    //存储人脸原始路径
                    if(null!=youtuPerson){
                        Map<String, Object> params = new HashMap<>(1);
                        params.put("personId", youtuPerson.getPersonId());
                        YoutuFace newYouTuFace = youtuFaceMapper.getByMapParams(params);
                        if(null!=newYouTuFace){
                            newYouTuFace.setWebUrl(url);
                            newYouTuFace.setDevicePath(picUrl);
                            youtuFaceMapper.update(newYouTuFace);
                        }
                    }
                }
            }
        } catch (Exception e) {
            log.error("********新增或者删除人脸异常********", e);
        }
    }

    @ApiOperation(value = "学校配置推送")
    @RequestMapping(value = "deleteWebankGroup", method = RequestMethod.POST)
    public ResultDTO<Object> deleteWebankGroup(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId) {
        try {
            //在此验证必传参数
            if (null == orgId) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }

            OrganizationWebank organizationWebank = organizationWebankService.getOrganizationWebanksByOrgId(orgId, null);

            if (null != organizationWebank && StringUtil.isNotEmptyIgnoreBlank(organizationWebank.getWebankAppid()) && StringUtil.isNotEmptyIgnoreBlank(organizationWebank.getWebankSecret())) {

                return new ResultDTO<>(webankUtilService.delGroup(UuIdUtil.getGroupIds(serviceConfig.getProfilesActive(), orgId.toString()), false, organizationWebank.getWebankAppid(), organizationWebank.getWebankSecret(), orgId));
            }

            return new ResultDTO();
        } catch (Exception e) {
            log.error("*************CampusController.deleteWebankGroup*************异常:{}", e.getMessage());
            return new ResultDTO(false);
        }
    }

    @ApiOperation(value = "用户人脸配置")
    @RequestMapping(value = "/saveUserFaceConfig", method = RequestMethod.POST)
    public ResultDTO<Object> saveUserFaceConfig(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "智慧校园学校ID", required = true) @RequestParam(name = "smartSchoolId", required = true) String smartOrgId,
            @ApiParam(value = "智慧校园用户ID", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId,
            @ApiParam(value = "用户类型:1学生2老师3家长", required = true) @RequestParam(name = "smartUserType", required = true) Short smartUserType,
            @ApiParam(value = "人脸相似度", required = true) @RequestParam(name = "similar", required = true) Short similar) {
        log.info("***********CampusController.saveUserFaceConfig******apiVersion:{},smartSchoolId:{},smartUserId:{},smartUserType:{}，similar:{}", apiVersion, smartOrgId, smartUserId, smartUserType, similar);
        try {
            if (StringUtils.isEmpty(smartOrgId) || StringUtils.isEmpty(smartUserId)) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }

            Long orgId = null;
            Long userId = null;

            Map<String, Object> orgParams = new HashMap<>();
            orgParams.put("smartOrgId", smartOrgId);
            Organization organization = organizationService.getByMapParams(orgParams);
            if (null != organization) {
                orgId = organization.getId();
            }

            if (null == organization) {
                return new ResultDTO<>(ErrorCode.ORGANIZATION_NOT_EXIST);
            }

            Map<String, Object> params = new HashMap<>(2);
            params.put("smartUserId", smartUserId);
            params.put("status", CommonStatusEnum.STARTSTATUS.getValue());

            switch (smartUserType) {
                case 1:
                    Student student = studentService.getByMapParams(params);
                    if (null != student) {
                        userId = student.getUserId();
                    }
                    break;
                case 2:
                    Employee employee = employeeService.getByMapParams(params);
                    if (null != employee) {
                        userId = employee.getUserId();
                    }
                    break;
                case 3:
                    Family family = familyService.getByMapParams(params);
                    if (null != family) {
                        userId = family.getUserId();
                    }
                    break;
                default:
                    break;
            }

            //为空不操作
            log.info("******saveUserFaceConfig***orgId:{},userId:{}***", orgId, userId);
            if (null == userId) {
                return new ResultDTO<>(ErrorCode.USER_NOT_EXIST);
            }

            Map<String, Object> paramMap = new HashMap<String, Object>();
            paramMap.put("orgId", orgId);
            paramMap.put("userId", userId);

            List<UserFacePersonConfig> facePersonConfigList = userFaceService.getUserFacePersonConfigList(paramMap);
            if (facePersonConfigList.isEmpty()) {
                List<UserFacePersonConfig> userFacePersonConfigList = new ArrayList<>();
                List<YoutuPerson> userFaceList = youTuService.youtuPersonList(paramMap);
                for (YoutuPerson youtuPerson : userFaceList) {
                    UserFacePersonConfig userFacePersonConfig = new UserFacePersonConfig();
                    userFacePersonConfig.setOrgId(orgId);
                    userFacePersonConfig.setUserId(userId);
                    userFacePersonConfig.setPersonId(youtuPerson.getPersonId());
                    userFacePersonConfig.setBanFlag(false);
                    userFacePersonConfig.setSimilar(similar);
                    userFacePersonConfig.setStatus(true);

                    userFacePersonConfigList.add(userFacePersonConfig);
                }

                if (!userFacePersonConfigList.isEmpty()) {
                    userFaceService.saveUserFacePersonConfig(userFacePersonConfigList);
                }
            }

        } catch (Exception e) {
            log.error("***********CampusController.saveUserLeave******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
        return new ResultDTO<>();
    }

    public String countUpdateFamily(String CampusController, String updateCampusFamily, String smartOrgId, String smartUserId) {
        return RedisKeyConstant.WKBB_BASIC + CampusController + ":" + updateCampusFamily + ":" + "smartOrgId" + ":" + smartOrgId + "smartUserId" + ":" + smartUserId;
    }

    public String countInsertFamily(String CampusController, String updateCampusFamily, String smartOrgId, String smartUserId) {
        return RedisKeyConstant.WKBB_BASIC + CampusController + ":" + updateCampusFamily + ":" + "smartOrgId" + ":" + smartOrgId + "smartUserId" + ":" + smartUserId;
    }

    public String errorFamily(String CampusController, String updateCampusFamily, String smartOrgId, String smartUserId) {
        return RedisKeyConstant.WKBB_BASIC + CampusController + ":" + updateCampusFamily + ":" + "smartOrgId" + ":" + smartOrgId + ":" + "smartUserId" + ":" + smartUserId;
    }

    public void saveUserInfoRedis(String countControllerNum) {
        if (null == redisTemplateUtil.get(countControllerNum)) {
            redisTemplateUtil.set(countControllerNum, 1, RedisKeyConstant.EXPIRATION_TIME_24_HOUR);
        } else {
            Long num = Long.valueOf(redisTemplateUtil.get(countControllerNum) + "");
            redisTemplateUtil.set(countControllerNum, ++num, RedisKeyConstant.EXPIRATION_TIME_24_HOUR);
        }
    }

    public void saveUserInfoRedis(String countControllerNum, Object object) {
        if (null == redisTemplateUtil.get(countControllerNum)) {
            redisTemplateUtil.set(countControllerNum, object, RedisKeyConstant.EXPIRATION_TIME_24_HOUR);
        } else {
            redisTemplateUtil.set(countControllerNum, object, RedisKeyConstant.EXPIRATION_TIME_24_HOUR);
        }
    }


    @ApiOperation(value = "查询学生家长")
    @RequestMapping(value = "/getFamilyListBySmartUserId", method = RequestMethod.GET)
    public ResultDTO<List<FamilyInfoDto>> getFamilyListBySmartUserId(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "学生用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId) {

        log.info("***********CampusController.getFamilyListBySmartUserId******apiVersion:{},userId:{}", apiVersion, userId);

        try {

            Map<String, Object> params = new HashMap<>();
            params.put("studentId", userId);

            return new ResultDTO<>(familyService.getFamilyInfoListByClassId(params));

        } catch (Exception e) {
            log.error("***********CampusController.getFamilyListBySmartUserId******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "通过学校ID查询班级列表")
    @RequestMapping(value = "/getCpClassListByOrg", method = RequestMethod.GET)
    public ResultDTO<List<ClassInfoDto>> getCpClassListByOrg(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId) {
        log.info("***********ClassInfoController.list******apiVersion:{},orgId:{},gradeId:{},className:{},masterName:{}",
                apiVersion, orgId);
        try {
            if (orgId == 0) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }

            Map<String, Object> params = new HashMap<>(2);
            params.put("orgId", orgId);
            params.put("status", 1);

            return new ResultDTO<>(classInfoService.getCpClassListByOrg(params));
        } catch (Exception e) {
            log.error("***********CampusController.getCpClassListByOrg******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "根据SmartUserId查询家长学生列表")
    @RequestMapping(value = "/getFamilyListByFamilySmartUserId", method = RequestMethod.GET)
    public ResultDTO<List<FamilyInfoDto>> getFamilyListByFamilySmartUserId(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "组织ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "家长表id", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId
    ) {
        log.info("***********CampusController.getFamilyListByFamilySmartUserId******...apiVersion:{},Employee:{}", apiVersion, smartUserId);
        try {
            Map<String, Object> params = new HashMap<>(3);
            params.put("orgId", orgId);
            params.put("smartUserId", smartUserId);
            params.put("status", CommonStatusEnum.STARTSTATUS.getValue());
            List<FamilyInfoDto> familyList = familyService.getFamilyListByFamilySmartUserId(params);
            return new ResultDTO<>(familyList);
        } catch (Exception e) {
            log.error("***********CampusController.getFamilyListByFamilySmartUserId******", e);
            return new ResultDTO<>(false);
        }
    }

    @ApiOperation(value = "智慧校园用户手机号修改")
    @RequestMapping(value = "/updateCampusMobile", method = RequestMethod.GET)
    public ResultDTO updateCampusMobile(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "smartUserId", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId,
            @ApiParam(value = "新的手机号", required = true) @RequestParam(name = "mobile", required = true) String mobile
    ) {
        log.info("***********CampusController.updateCampusMobile******apiVersion:{},orgId:{},smartUserId:{}",
                apiVersion, orgId,smartUserId);
        try {
            if (null==orgId||StringUtil.isEmptyIgnoreBlank(smartUserId)||StringUtil.isEmptyIgnoreBlank(mobile)) {
                return new ResultDTO<>(ErrorCode.PARAM_MISSING);
            }
            Boolean flag=false;

            Map<String, Object> params = new HashMap<>(3);
            params.put("orgId", orgId);
            params.put("smartUserId", smartUserId);
            Employee employee = employeeService.getByMapParams(params);

            Long userId=null;

            List<Family> familyList = familyService.getListByMapParams(params);
            if(null!=employee){
                employee.setMobile(mobile);
                employeeService.update(employee);
                flag=true;
                userId=employee.getUserId();
            }


            if(CollectionUtils.isNotEmpty(familyList)){
                for(Family family:familyList){
                    family.setMobile(mobile);
                    familyService.update(family);
                    userId=family.getUserId();
                }
                flag=true;
            }

            if(flag){
                User user = userService.getByPrimaryKey(userId);
                if(null!=user){
                    user.setMobile(mobile);
                    userService.update(user);
                }
            }
            return new ResultDTO<>();
        } catch (Exception e) {
            log.error("***********CampusController.updateCampusMobile******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }
    }

    @ApiOperation(value = "智慧校园人脸转企微人脸")
    @RequestMapping(value = "/changeUserFace", method = RequestMethod.POST)
    public ResultDTO changeUserId(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "智慧校园在3.0的学校ID", required = true) @RequestParam(name = "camOrgId", required = true) Long camOrgId,
            @ApiParam(value = "智慧校园在3.0的班级ID", required = false) @RequestParam(name = "camClassId", required = false) Long camClassId,
            @ApiParam(value = "企业微信在3.0的学校ID", required = true) @RequestParam(name = "wxOrgId", required = true) Long wxOrgId,
            @ApiParam(value = "企业微信在3.0的班级ID", required = false) @RequestParam(name = "wxClassId", required = false) Long wxClassId
    ){
        log.info("***********CampusController.changeUserFace******camOrgId:{},camClassId:{} wxOrgId:{} wxClassId:{}",camOrgId,camClassId,wxOrgId,wxClassId);
        try {
            userOpenService.changeUserFace(camOrgId,camClassId,wxOrgId,wxClassId);
            return new ResultDTO<>();
        } catch (Exception e) {
            log.error("***********CampusController.changeUserFace******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }

    }

    @ApiOperation(value = "同步学生人脸到企微学校(班级名称,年级名称,学生姓名必须一致)")
    @RequestMapping(value = "/synCpWxUserFace", method = RequestMethod.POST)
    public ResultDTO synCpWxUserFace(
            @ApiParam(value = "接口版本", required = true, defaultValue = VersionConstant.V1) @PathVariable(value = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "智慧校园在3.0的学校ID", required = true) @RequestParam(name = "camOrgId", required = true) Long camOrgId,
            @ApiParam(value = "企业微信在3.0的学校ID", required = true) @RequestParam(name = "wxOrgId", required = true) Long wxOrgId
    ){
        log.info("***********CampusController.changeUserId******camOrgId:{},wxOrgId:{}",camOrgId,wxOrgId);
        try {

            userOpenService.synCpWxUserFace(camOrgId,wxOrgId);
            return new ResultDTO<>();
        } catch (Exception e) {
            log.error("***********CampusController.changeUserId******", e);
            return new ResultDTO<>(ErrorCode.SYSTEM_EXCEPTION);
        }

    }

    @ApiOperation(value = "根据SmartUserId获取用户列表")
    @RequestMapping(value = "/getUserListBySmartUserId", method = RequestMethod.GET)
    public ResultDTO<List<UserInfoDto>> getUserListBySmartUserId(
            @ApiParam(value = "接口版本", defaultValue = VersionConstant.V1, required = true) @PathVariable(name = "apiVersion") String apiVersion,
            @ApiParam(value = "来源类型（1:自营 2:智慧校园）", required = true) @RequestParam(name = "originType", required = true) Integer originType,
            @ApiParam(value = "智慧校园学校ID", required = false) @RequestParam(name = "smartOrgId", required = false) String smartOrgId,
            @ApiParam(value = "用户类型:1学生2老师3家长", required = true) @RequestParam(name = "smartUserType", required = true) Short smartUserType,
            @ApiParam(value = "智慧校园用户ID", required = true) @RequestParam(name = "smartUserId", required = true) String smartUserId)
    {
        log.info("***********CampusController.getUserListBySmartUserId******smartOrgId:{},smartUserId:{},smartUserType:{}", smartOrgId, smartUserId, smartUserType);
        try {

            List<UserInfoDto> userInfoDtoList = new ArrayList<UserInfoDto>();

            //查询学校
            Map<String, Object> params = new HashMap<>();
            if(StringUtil.isNotEmpty(smartOrgId)) {
                Map<String, Object> orgParams = new HashMap<>();
                orgParams.put("smartOrgId", smartOrgId);
                Organization organization = organizationService.getByMapParams(orgParams);
                if(null!=organization)
                {
                    params.put("orgId", organization.getId());
                }
            }
            params.put("smartUserId", smartUserId);

            switch (smartUserType) {
                case 1:
                    List<Student> studentList = studentService.getListByMapParams(params);
                    for(Student student : studentList)
                    {
                        UserInfoDto userInfoDto = new UserInfoDto();
                        BeanUtils.copyProperties(student,userInfoDto);
                        userInfoDto.setId(student.getUserId());
                        userInfoDtoList.add(userInfoDto);
                    }
                    break;
                case 2:
                    List<Employee> employeeList = employeeService.getListByMapParams(params);
                    for(Employee employee : employeeList)
                    {
                        UserInfoDto userInfoDto = new UserInfoDto();
                        BeanUtils.copyProperties(employee,userInfoDto);
                        userInfoDto.setId(employee.getUserId());
                        userInfoDtoList.add(userInfoDto);
                    }
                    break;
                case 3:
                    List<Family> familyList = familyService.getListByMapParams(params);
                    for(Family family : familyList)
                    {
                        UserInfoDto userInfoDto = new UserInfoDto();
                        BeanUtils.copyProperties(family,userInfoDto);
                        userInfoDto.setId(family.getUserId());
                        userInfoDtoList.add(userInfoDto);
                    }
                    break;
                default:
                    break;
            }

            return new ResultDTO(userInfoDtoList);
        } catch (Exception e) {
            log.error("***********CampusController.getUserListBySmartUserId******", e);
            return new ResultDTO<>(false);
        }
    }
}